home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
tcoop10a.zip
/
DEMO.ZIP
/
TESTEFFE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-11-20
|
2KB
|
127 lines
//
// EFFECT.CPP
// version 1.00 11/20/91
// sound effects generator
// copyright (c) 1991 by James S. Clark
// all rights reserved
//
#include <dos.h> // delay()
#include <conio.h> // getch()
#include <stdlib.h> // random()
#include "effect.hpp"
void Effect::generator(int wave, int time, int f1, int f2,
int step, int dur)
{
int currtime = 0;
int f, dx = step;
if (f1 < f2) { f = f1; f1 = f2; f2 = f1; }
f = f2;
switch (wave) {
case SQUARE:
while (currtime < time) {
submit(f1, step);
submit(f2, dur);
currtime += step;
currtime += dur;
}
break;
case TRIANGLE:
while (currtime < time) {
submit(f, dur);
f += dx;
if (f > f1) dx = -dx;
if (f < f2) dx = -dx;
currtime += dur;
}
break;
case RAMPUP:
while (currtime < time) {
submit(f, dur);
f += step;
if (f > f1) f = f2;
currtime += dur;
}
break;
case RAMPDOWN: {
f = f1;
while (currtime < time) {
submit(f, dur);
f -= step;
if (f < f2) f = f1;
currtime += dur;
}
}
break;
case RANDOM:
while (currtime < time) {
f = f2 + random(f1 - f2);
f1 -= step;
submit(f, dur);
currtime += dur;
}
break;
}
submit(0, 0);
}
// char *effectnames[] = {
// "alarm", "bomb", "computer", "explode", "explode2",
// "laser", "phone", "police", "raygun", "tinkle"
// }
main()
{
Effect fx;
int i;
fx.alarm(4000);
delay(5000);
fx.flush();
fx.bomb(4000);
delay(5000);
fx.flush();
fx.computer(4000);
delay(5000);
fx.flush();
fx.explode(4000);
delay(5000);
fx.flush();
fx.explode2(4000);
delay(5000);
fx.flush();
fx.laser(4000);
delay(5000);
fx.flush();
fx.phone(4000);
delay(5000);
fx.flush();
fx.police(4000);
delay(5000);
fx.flush();
fx.raygun(4000);
delay(5000);
fx.flush();
fx.tinkle(4000);
delay(5000);
fx.flush();
};